package com.humngyang.com.hmy.study.concurrency.myannoations.immutable;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.humngyang.com.hmy.study.concurrency.myannoations.ThreadSafe;
import jdk.nashorn.internal.ir.annotations.Immutable;

import java.util.Collections;
import java.util.Map;

@ThreadSafe
public class immutableExample2 {

    private final static ImmutableList list = ImmutableList.of(1,2,3);
    private final static ImmutableSet set = ImmutableSet.copyOf(list);
    //使用guava创建Map
    private final static ImmutableMap map = ImmutableMap.of(1,2,3,4,5,6);
    //使用>builder()方式创建一个集合。
    private final static ImmutableMap map2 = ImmutableMap.<Integer,Integer>builder().put(1,2).put(3,4).put(5,6).build();


    public static void main(String[] args) {
        //使用guava的Maps创建一个Map集合
        //Map mapss = Maps.newHashMap();
        // 可知当声明ImmutableList的时候，是不能修改的。
        map.put(6,7);
        System.out.println(set);
        System.out.println(list);

    }


}
